import base64


def base64_encode(text):
    text_bytes = text.encode('utf-8')
    encoded_bytes = base64.b64encode(text_bytes)
    return encoded_bytes.decode('utf-8')


def base64_decode(text):
    try:
        encoded_bytes = text.encode('utf-8')
        decoded_bytes = base64.b64decode(encoded_bytes)
        return decoded_bytes.decode('utf-8')
    except base64.binascii.Error:
        return "无效的 Base64 编码"
    